package com.blockmeta.bbs.immodule.corebean.Impl;

import android.content.Context;

import com.blockmeta.bbs.businesslibrary.flutter.MethodChannelFlutterPlugins;
import com.blockmeta.bbs.businesslibrary.util.AccountHelper;
import com.blockmeta.bbs.immodule.corebean.ITodoDomainService;
import com.blockmeta.bbs.immodule.dao.Todo;
import com.blockmeta.bbs.immodule.greendao.repository.ITodoRepo;

import java.util.List;

public class TodoDomainService implements ITodoDomainService {
    final Context mContext;
    ITodoRepo todoRepo;


    public TodoDomainService(Context context) {
        mContext = context;
        todoRepo = IMRepoContext.getTodoRepo(context);
    }

    @Override
    public int getMaxTodoIdByUserId(long userId) {
        return todoRepo.getMaxTodoIdByUserId(userId);
    }

    @Override
    public List<Todo> getGroupTodoList(long uidInt, long mCircleId) {
        return todoRepo.getGroupTodoList(uidInt, mCircleId);
    }

    @Override
    public List<Todo> getAllTodoList(long uidInt) {
        return todoRepo.getAllTodoList(uidInt);
    }

    @Override
    public void updateTodo(long todoId, boolean b, boolean agreeOrNot, String s) {
        todoRepo.updateTodo(todoId, b, agreeOrNot, s, AccountHelper.getUidInt());
    }

    @Override
    public Todo getCircleLasteatUnCompleteTodo(long mCircleId, long uidInt) {
        return todoRepo.getCircleLasteatUnCompleteTodo(mCircleId, uidInt);
    }

    @Override
    public long getAddFriendUnDoTodoCount(long uidInt) {
        return todoRepo.getAddFriendUnDoTodoCount(uidInt);
    }

    @Override
    public Todo getAddFriendLasteatUnCompleteTodo(long uidInt) {
        return todoRepo.getAddFriendLasteatUnCompleteTodo(uidInt);
    }

    @Override
    public List<Todo> getTodoList(long parseInt) {
        return todoRepo.getTodoList(parseInt);
    }

    @Override
    public void addTodo(Todo todo) {
        todoRepo.addTodo(todo, AccountHelper.getUidInt());
    }

    @Override
    public void deleteTodo(long todoId) {
        todoRepo.deleteTodo(todoId, AccountHelper.getUidInt());

    }

    @Override
    public void sendUncheckCountEvent() {
        int count = todoRepo.countUnCompleteTodo(AccountHelper.getUidInt());
        MethodChannelFlutterPlugins.send("unReadTodo", count);
    }
}
